<?

function html_attributes($attributes){
    $html_attributes = '';
    foreach($attributes as $attr_name => $attr_value):
        $html_attributes .= "$attr_name=\"$attr_value\" ";
    endforeach;
    return $html_attributes;
}

function url($controller, $method = 'index', $args = array()){
    $url = implode('/', array_merge(array($controller, $method), $args));
    return BASE_URL . $url;
}

function link_to($text, $controller, $method = 'index', $args = array(), $html = array()){
    return '<a href="' . url($controller, $method, $args) . '"'. html_attributes($html) . '>' . $text . '</a>';
}

?>
